<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/3
 * Time: 9:51
 */

namespace App\Services;


use App\Role;
use App\User;

class UserService
{
    public function createSuperAdmin()
    {
        //超级管理员用户
        $user = User::create([
            'username' => config('admin.username'),
            'name'     => config('admin.name'),
            'password' => bcrypt(config('admin.password')),
        ]);
        //超级管理员角色
        $admin = new Role();
        $admin->name = 'admin';
        $admin->display_name = '超级管理员';
        $admin->description = '能管理所有的权限';
        $admin->save();
        //建立关联
        $user->attachRole($admin);
    }
}
